package com.kye.express.business.jd.goods_list_by_category;

import com.kye.base.Logger;
import com.kye.express.business.jd.goods_list_by_category.model.JDCategorySelectModel;
import com.kye.express.business.jd.goods_list_by_category.model.JDCategoryTagModel;
import com.kye.express.business.jd.goods_list_by_category.model.JDIntegralScopeType;
import com.kye.express.business.jd.goods_list_by_category.model.JDIntegralSelectModel;
import com.kye.express.contract.base.BasePresenter;
import com.kye.express.contract.base.view.IView;
import com.kye.model.OpenApiResultObserver;
import com.kye.model.UserSession;
import com.kye.model.base.Data3ResultSet;
import com.kye.model.base.PageInfo;
import com.kye.model.bean.OpenApiResult;
import com.kye.model.bean.jd.shop.JDGoodsCategoryBean;
import com.kye.model.bean.jd.shop.JDGoodsItemBean;
import com.kye.model.bean.jd.shop.JDGoodsListResultBean;
import com.kye.model.bean.jd.shop.request.RequestJDGoodsCategories;
import com.kye.model.bean.jd.shop.request.RequestJDGoodsList;
import com.kye.model.bean.user.User;
import com.kye.model.datasource.JDShopDataSource;

import java.util.ArrayList;
import java.util.List;

import io.reactivex.Observable;
import io.reactivex.Single;
import io.reactivex.SingleObserver;
import io.reactivex.SingleSource;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.functions.Consumer;
import io.reactivex.functions.Function;
import io.reactivex.functions.Function3;
import io.reactivex.schedulers.Schedulers;

/**
 * @author : Joe
 * @version : 1.0
 * @editor : Joe
 * @created : 18/12/2017
 * @updated : 18/12/2017
 * @description : <Description>
 * @update_reason : <UpdateReason>
 */

public interface JDGoodsListByCategoryConstract {

    interface JDGoodsListByCategoryView extends IView {

        void onUser(User user);

        void onLoading();

        void onLoaded();

        void refreshInitServerFailed(String msg);

        void refreshInitNetFailed(String message);

        void updateCategoryTagListViews(Data3ResultSet<List<JDCategorySelectModel>, List<JDCategoryTagModel>, List<JDIntegralSelectModel>> data3ResultSet);

        void refreshGoodsInitSuccess(JDGoodsListResultBean jdGoodsListResultBean);

        void refreshGoodsInitServerFailed(String msg);

        void refreshGoodsInitNetFailed(String message);

        void refreshGoodsSuccess(JDGoodsListResultBean jdGoodsListResultBean);

        void refreshGoodsServerFailed(String msg);

        void refreshGoodsNetFailed(String message);

        void loadmoreGoodsSuccess(JDGoodsListResultBean jdGoodsListResultBean);

        void loadmoreGoodsServerFailed(String msg);

        void loadmoreGoodsNetFailed(String message);

        double getExchangeRate();
    }

    class JDGoodsListByCategoryPresenter extends BasePresenter<JDGoodsListByCategoryView> {

        private JDShopDataSource jdShopDataSource;
        private PageInfo pageInfo;

        public JDGoodsListByCategoryPresenter() {
            jdShopDataSource = new JDShopDataSource();
            pageInfo = PageInfo.newInstance();
        }

        @Override
        public void bind(JDGoodsListByCategoryView view) {
            super.bind(view);
            UserSession.getInstance()
                    .getUserForRx()
                    .compose(getView().bindToLifecycleDestroy())
                    .subscribe(new Consumer<User>() {
                        @Override
                        public void accept(User user) throws Exception {
                            getView().onUser(user);
                        }
                    });
        }

        /**
         * 首次刷新，获取当前类别的子类别，使用第一个类别，如果存在下一级，tag默认使用下一级的第一个类别
         * todo : 更新, 获取列表不通过网络请求
         *
         * @param userInfo
         * @param categoryBean
         */
        public void refreshInit(User userInfo, JDGoodsCategoryBean categoryBean) {
            Single.just(categoryBean)
                    .map(new Function<JDGoodsCategoryBean, List<JDGoodsCategoryBean>>() {
                        @Override
                        public List<JDGoodsCategoryBean> apply(JDGoodsCategoryBean jdGoodsCategoryBean) throws Exception {
                            /**
                             * 获取二级列表类别
                             */
                            return categoryBean.getNodes();
                        }
                    })
                    .subscribe(new SingleObserver<List<JDGoodsCategoryBean>>() {
                        @Override
                        public void onSubscribe(Disposable d) {

                        }

                        @Override
                        public void onSuccess(List<JDGoodsCategoryBean> jdGoodsCategoryBeans) {
                            /**
                             * todo : 初始化category list 和 tag list
                             */
                            initCategoryTagAndGoodsList(jdGoodsCategoryBeans);
                        }

                        @Override
                        public void onError(Throwable e) {
                            getView().refreshInitServerFailed(e.getMessage());
                        }
                    });
        }

        /**
         * 首次刷新，获取当前类别的子类别，使用第一个类别，如果存在下一级，tag默认使用下一级的第一个类别
         *
         * @param userInfo
         * @param categoryBean
         */
        @Deprecated
        public void refreshInitBak(User userInfo, JDGoodsCategoryBean categoryBean) {
            Single.just(new RequestJDGoodsCategories())
                    .doOnSuccess(new Consumer<RequestJDGoodsCategories>() {
                        @Override
                        public void accept(RequestJDGoodsCategories requestJDGoodsCategories) throws Exception {
                            requestJDGoodsCategories.setKySign("123456");
                            requestJDGoodsCategories.setID(String.valueOf(categoryBean.getId()));
                        }
                    })
                    .flatMap(new Function<RequestJDGoodsCategories, SingleSource<OpenApiResult<List<JDGoodsCategoryBean>>>>() {
                        @Override
                        public SingleSource<OpenApiResult<List<JDGoodsCategoryBean>>> apply(RequestJDGoodsCategories requestJDGoodsCategories) throws Exception {
                            return jdShopDataSource.getJDGoodsCategories(requestJDGoodsCategories)
                                    .compose(getView().bindToLifecycleDestroy());
                        }
                    })
                    .subscribe(new OpenApiResultObserver<List<JDGoodsCategoryBean>>() {
                        @Override
                        public void onLoading(Disposable d) {

                        }

                        @Override
                        public void onSuccess(OpenApiResult<List<JDGoodsCategoryBean>> result, List<JDGoodsCategoryBean> jdGoodsCategoryBeans) {
                            /**
                             * todo : 初始化category list 和 tag list
                             */
                            initCategoryTagAndGoodsList(jdGoodsCategoryBeans);
                        }

                        @Override
                        public void onApiError(OpenApiResult<List<JDGoodsCategoryBean>> result, int code, String msg) {
                            getView().refreshInitServerFailed(msg);
                        }

                        @Override
                        public void onOtherError(Throwable e) {
                            getView().refreshInitNetFailed(e.getMessage());
                        }

                        @Override
                        public void onLoaded() {

                        }
                    });
        }

        /**
         * 初始化category list and tag list then to get goods list
         *
         * @param jdGoodsCategoryBeans
         */
        private void initCategoryTagAndGoodsList(List<JDGoodsCategoryBean> jdGoodsCategoryBeans) {
            if (jdGoodsCategoryBeans.size() <= 0) {
                return;
            }
            /**
             * todo : get the category tag list from category list
             */
            Single<List<JDCategoryTagModel>> categoryTagSingle = Observable.fromIterable(jdGoodsCategoryBeans.get(0).getNodes())
                    .map(new Function<JDGoodsCategoryBean, JDCategoryTagModel>() {
                        @Override
                        public JDCategoryTagModel apply(JDGoodsCategoryBean jdGoodsCategoryBean) throws Exception {
                            JDCategoryTagModel tagModel = new JDCategoryTagModel();
                            tagModel.setGoodsCategoryBean(jdGoodsCategoryBean);
                            tagModel.setSelected(false);
                            return tagModel;
                        }
                    })
                    .toList()
                    .doOnSuccess(new Consumer<List<JDCategoryTagModel>>() {
                        @Override
                        public void accept(List<JDCategoryTagModel> jdCategoryTagModels) throws Exception {
                            if (jdCategoryTagModels != null && jdCategoryTagModels.size() > 0) {
                                jdCategoryTagModels.get(0).setSelected(true);
                            }
                        }
                    });
            /**
             * todo : get the category list
             */
            Single<List<JDCategorySelectModel>> categorySelectSingle = Observable.fromIterable(jdGoodsCategoryBeans)
                    .map(new Function<JDGoodsCategoryBean, JDCategorySelectModel>() {
                        @Override
                        public JDCategorySelectModel apply(JDGoodsCategoryBean jdGoodsCategoryBean) throws Exception {
                            JDCategorySelectModel categorySelectModel = new JDCategorySelectModel();
                            categorySelectModel.setGoodsCategoryBean(jdGoodsCategoryBean);
                            categorySelectModel.setSelected(false);
                            return categorySelectModel;
                        }
                    })
                    .toList()
                    .doOnSuccess(new Consumer<List<JDCategorySelectModel>>() {
                        @Override
                        public void accept(List<JDCategorySelectModel> jdCategorySelectModels) throws Exception {
                            jdCategorySelectModels.get(0).setSelected(true);
                        }
                    });
            /**
             * todo : get the intergal scope list
             */
            Single<List<JDIntegralSelectModel>> integralSelectSingle = Single.just(new ArrayList<JDIntegralSelectModel>())
                    .doOnSuccess(new Consumer<ArrayList<JDIntegralSelectModel>>() {
                        @Override
                        public void accept(ArrayList<JDIntegralSelectModel> jdIntegralSelectModels) throws Exception {
                            JDIntegralSelectModel level1Model = new JDIntegralSelectModel(JDIntegralScopeType.TYPE_LEVEL_1, true);
                            JDIntegralSelectModel level2Model = new JDIntegralSelectModel(JDIntegralScopeType.TYPE_LEVEL_2, false);
                            JDIntegralSelectModel level3Model = new JDIntegralSelectModel(JDIntegralScopeType.TYPE_LEVEL_3, false);
                            JDIntegralSelectModel level4Model = new JDIntegralSelectModel(JDIntegralScopeType.TYPE_LEVEL_4, false);
                            jdIntegralSelectModels.add(level1Model);
                            jdIntegralSelectModels.add(level2Model);
                            jdIntegralSelectModels.add(level3Model);
                            jdIntegralSelectModels.add(level4Model);
                        }
                    })
                    .map(new Function<ArrayList<JDIntegralSelectModel>, List<JDIntegralSelectModel>>() {
                        @Override
                        public List<JDIntegralSelectModel> apply(ArrayList<JDIntegralSelectModel> jdIntegralSelectModels) throws Exception {
                            return jdIntegralSelectModels;
                        }
                    });
            /**
             * todo : zip data for view display
             */
            Single
                    .zip(categorySelectSingle, categoryTagSingle, integralSelectSingle, new Function3<List<JDCategorySelectModel>, List<JDCategoryTagModel>, List<JDIntegralSelectModel>, Data3ResultSet<List<JDCategorySelectModel>, List<JDCategoryTagModel>, List<JDIntegralSelectModel>>>() {
                        @Override
                        public Data3ResultSet<List<JDCategorySelectModel>, List<JDCategoryTagModel>, List<JDIntegralSelectModel>> apply(List<JDCategorySelectModel> jdCategorySelectModels, List<JDCategoryTagModel> jdCategoryTagModels, List<JDIntegralSelectModel> jdIntegralSelectModels) throws Exception {
                            return new Data3ResultSet<>(jdCategorySelectModels, jdCategoryTagModels, jdIntegralSelectModels);
                        }
                    })
                    .subscribeOn(Schedulers.io())
                    .observeOn(AndroidSchedulers.mainThread())
                    .subscribe(new SingleObserver<Data3ResultSet<List<JDCategorySelectModel>, List<JDCategoryTagModel>, List<JDIntegralSelectModel>>>() {
                        @Override
                        public void onSubscribe(Disposable d) {

                        }

                        @Override
                        public void onSuccess(Data3ResultSet<List<JDCategorySelectModel>, List<JDCategoryTagModel>, List<JDIntegralSelectModel>> listListListData3ResultSet) {
                            Logger.d("onSuccess : ");
                            getView().updateCategoryTagListViews(listListListData3ResultSet);
                        }

                        @Override
                        public void onError(Throwable e) {
                            Logger.e(e, e.getMessage());
                        }
                    });
        }

        /**
         * 首次刷新商品列表
         * @param userInfo
         * @param selectedCategoryModel
         * @param selectedTagModel
         * @param selectIntegralModel
         */
        public void refreshGoodsInit(
                User userInfo,
                JDCategorySelectModel selectedCategoryModel,
                JDCategoryTagModel selectedTagModel,
                JDIntegralSelectModel selectIntegralModel) {
            Single.just(new RequestJDGoodsList())
                    .doOnSuccess(new Consumer<RequestJDGoodsList>() {
                        @Override
                        public void accept(RequestJDGoodsList requestJDGoodsList) throws Exception {
                            requestJDGoodsList.setPhone(userInfo.getPhone());
                            requestJDGoodsList.setKySign("123456");
                            requestJDGoodsList.setPageIndex(PageInfo.INDEX_DEFAULT);
                            requestJDGoodsList.setPageSize(PageInfo.SIZE_DEFAULT);
                            if (selectedTagModel != null && selectedTagModel.getGoodsCategoryBean().getId() > 0) {
                                requestJDGoodsList.setClassId(String.valueOf(selectedTagModel.getGoodsCategoryBean().getId()));
                            } else {
                                requestJDGoodsList.setClassId(String.valueOf(selectedCategoryModel.getGoodsCategoryBean().getId()));
                            }
                            requestJDGoodsList.setMinPrice(String.valueOf(selectIntegralModel.getScopeType().getFrom()));
                            requestJDGoodsList.setMaxPrice(String.valueOf(selectIntegralModel.getScopeType().getTo()));
                        }
                    })
                    .flatMap(new Function<RequestJDGoodsList, SingleSource<OpenApiResult<JDGoodsListResultBean>>>() {
                        @Override
                        public SingleSource<OpenApiResult<JDGoodsListResultBean>> apply(RequestJDGoodsList requestJDGoodsList) throws Exception {
                            return jdShopDataSource.getJDGoodsList(requestJDGoodsList)
                                    .compose(getView().bindToLifecycleDestroy())
                                    .doOnSuccess(new Consumer<OpenApiResult<JDGoodsListResultBean>>() {
                                        @Override
                                        public void accept(OpenApiResult<JDGoodsListResultBean> jdGoodsListResultBeanOpenApiResult) throws Exception {
                                            if (jdGoodsListResultBeanOpenApiResult.isSuccess()) {
                                                List<JDGoodsItemBean> datas = jdGoodsListResultBeanOpenApiResult.getData().getDatas();
                                                for (JDGoodsItemBean goodsItem :
                                                        datas) {
                                                    goodsItem.setExchangeRate(getView().getExchangeRate());
                                                }
                                            }
                                        }
                                    });
                        }
                    })
                    .doOnSuccess(new Consumer<OpenApiResult<JDGoodsListResultBean>>() {
                        @Override
                        public void accept(OpenApiResult<JDGoodsListResultBean> jdGoodsListResultBeanOpenApiResult) throws Exception {
                            if (jdGoodsListResultBeanOpenApiResult.isSuccess()) {
                                List<JDGoodsItemBean> datas = jdGoodsListResultBeanOpenApiResult.getData().getDatas();
                                for (JDGoodsItemBean goodsItemBean : datas) {
                                    goodsItemBean.setImagePath("http://img13.360buyimg.com/n0/" + goodsItemBean.getImagePath());
                                }
                            }
                        }
                    })
                    .subscribeOn(Schedulers.io())
                    .observeOn(AndroidSchedulers.mainThread())
                    .subscribe(new OpenApiResultObserver<JDGoodsListResultBean>() {
                        @Override
                        public void onLoading(Disposable d) {

                        }

                        @Override
                        public void onSuccess(OpenApiResult<JDGoodsListResultBean> result, JDGoodsListResultBean jdGoodsListResultBean) {
                            pageInfo.resetPage();
                            getView().refreshGoodsInitSuccess(jdGoodsListResultBean);
                        }

                        @Override
                        public void onApiError(OpenApiResult<JDGoodsListResultBean> result, int code, String msg) {
                            getView().refreshGoodsInitServerFailed(msg);
                        }

                        @Override
                        public void onOtherError(Throwable e) {
                            getView().refreshGoodsInitNetFailed(e.getMessage());
                        }

                        @Override
                        public void onLoaded() {

                        }
                    });
        }

        /**
         * 下拉刷新
         * @param userInfo
         * @param selectedCategoryModel
         * @param selectedTagModel
         * @param selectIntegralModel
         */
        public void refreshGoods(
                User userInfo,
                JDCategorySelectModel selectedCategoryModel,
                JDCategoryTagModel selectedTagModel,
                JDIntegralSelectModel selectIntegralModel) {
            Single.just(new RequestJDGoodsList())
                    .doOnSuccess(new Consumer<RequestJDGoodsList>() {
                        @Override
                        public void accept(RequestJDGoodsList requestJDGoodsList) throws Exception {
                            requestJDGoodsList.setPhone(userInfo.getPhone());
                            requestJDGoodsList.setKySign("123456");
                            requestJDGoodsList.setPageIndex(PageInfo.INDEX_DEFAULT);
                            requestJDGoodsList.setPageSize(PageInfo.SIZE_DEFAULT);
                            if (selectedTagModel != null && selectedTagModel.getGoodsCategoryBean().getId() > 0) {
                                requestJDGoodsList.setClassId(String.valueOf(selectedTagModel.getGoodsCategoryBean().getId()));
                            } else {
                                requestJDGoodsList.setClassId(String.valueOf(selectedCategoryModel.getGoodsCategoryBean().getId()));
                            }
                            requestJDGoodsList.setMinPrice(String.valueOf(selectIntegralModel.getScopeType().getFrom()));
                            requestJDGoodsList.setMaxPrice(String.valueOf(selectIntegralModel.getScopeType().getTo()));
                        }
                    })
                    .flatMap(new Function<RequestJDGoodsList, SingleSource<OpenApiResult<JDGoodsListResultBean>>>() {
                        @Override
                        public SingleSource<OpenApiResult<JDGoodsListResultBean>> apply(RequestJDGoodsList requestJDGoodsList) throws Exception {
                            return jdShopDataSource.getJDGoodsList(requestJDGoodsList)
                                    .compose(getView().bindToLifecycleDestroy())
                                    .doOnSuccess(new Consumer<OpenApiResult<JDGoodsListResultBean>>() {
                                        @Override
                                        public void accept(OpenApiResult<JDGoodsListResultBean> jdGoodsListResultBeanOpenApiResult) throws Exception {
                                            if (jdGoodsListResultBeanOpenApiResult.isSuccess()) {
                                                List<JDGoodsItemBean> datas = jdGoodsListResultBeanOpenApiResult.getData().getDatas();
                                                for (JDGoodsItemBean goodsItem :
                                                        datas) {
                                                    goodsItem.setExchangeRate(getView().getExchangeRate());
                                                }
                                            }
                                        }
                                    });
                        }
                    })
                    .doOnSuccess(new Consumer<OpenApiResult<JDGoodsListResultBean>>() {
                        @Override
                        public void accept(OpenApiResult<JDGoodsListResultBean> jdGoodsListResultBeanOpenApiResult) throws Exception {
                            if (jdGoodsListResultBeanOpenApiResult.isSuccess()) {
                                List<JDGoodsItemBean> datas = jdGoodsListResultBeanOpenApiResult.getData().getDatas();
                                for (JDGoodsItemBean goodsItemBean : datas) {
                                    goodsItemBean.setImagePath("http://img13.360buyimg.com/n0/" + goodsItemBean.getImagePath());
                                }
                            }
                        }
                    })
                    .subscribeOn(Schedulers.io())
                    .observeOn(AndroidSchedulers.mainThread())
                    .subscribe(new OpenApiResultObserver<JDGoodsListResultBean>() {
                        @Override
                        public void onLoading(Disposable d) {

                        }

                        @Override
                        public void onSuccess(OpenApiResult<JDGoodsListResultBean> result, JDGoodsListResultBean jdGoodsListResultBean) {
                            pageInfo.resetPage();
                            getView().refreshGoodsSuccess(jdGoodsListResultBean);
                        }

                        @Override
                        public void onApiError(OpenApiResult<JDGoodsListResultBean> result, int code, String msg) {
                            getView().refreshGoodsServerFailed(msg);
                        }

                        @Override
                        public void onOtherError(Throwable e) {
                            getView().refreshGoodsNetFailed(e.getMessage());
                        }

                        @Override
                        public void onLoaded() {

                        }
                    });
        }

        /**
         * 加载更多
         * @param userInfo
         * @param selectedCategoryModel
         * @param selectedTagModel
         * @param selectIntegralModel
         */
        public void loadmoreGoods(
                User userInfo,
                JDCategorySelectModel selectedCategoryModel,
                JDCategoryTagModel selectedTagModel,
                JDIntegralSelectModel selectIntegralModel) {
            Single.just(new RequestJDGoodsList())
                    .doOnSuccess(new Consumer<RequestJDGoodsList>() {
                        @Override
                        public void accept(RequestJDGoodsList requestJDGoodsList) throws Exception {
                            requestJDGoodsList.setPhone(userInfo.getPhone());
                            requestJDGoodsList.setKySign("123456");
                            requestJDGoodsList.setPageIndex(pageInfo.getPageIndex());
                            requestJDGoodsList.setPageSize(pageInfo.getPageSize());
                            if (selectedTagModel != null && selectedTagModel.getGoodsCategoryBean().getId() > 0) {
                                requestJDGoodsList.setClassId(String.valueOf(selectedTagModel.getGoodsCategoryBean().getId()));
                            } else {
                                requestJDGoodsList.setClassId(String.valueOf(selectedCategoryModel.getGoodsCategoryBean().getId()));
                            }
                            requestJDGoodsList.setMinPrice(String.valueOf(selectIntegralModel.getScopeType().getFrom()));
                            requestJDGoodsList.setMaxPrice(String.valueOf(selectIntegralModel.getScopeType().getTo()));
                        }
                    })
                    .flatMap(new Function<RequestJDGoodsList, SingleSource<OpenApiResult<JDGoodsListResultBean>>>() {
                        @Override
                        public SingleSource<OpenApiResult<JDGoodsListResultBean>> apply(RequestJDGoodsList requestJDGoodsList) throws Exception {
                            return jdShopDataSource.getJDGoodsList(requestJDGoodsList)
                                    .compose(getView().bindToLifecycleDestroy())
                                    .doOnSuccess(new Consumer<OpenApiResult<JDGoodsListResultBean>>() {
                                        @Override
                                        public void accept(OpenApiResult<JDGoodsListResultBean> jdGoodsListResultBeanOpenApiResult) throws Exception {
                                            if (jdGoodsListResultBeanOpenApiResult.isSuccess()) {
                                                List<JDGoodsItemBean> datas = jdGoodsListResultBeanOpenApiResult.getData().getDatas();
                                                for (JDGoodsItemBean goodsItem :
                                                        datas) {
                                                    goodsItem.setExchangeRate(getView().getExchangeRate());
                                                }
                                            }
                                        }
                                    });
                        }
                    })
                    .doOnSuccess(new Consumer<OpenApiResult<JDGoodsListResultBean>>() {
                        @Override
                        public void accept(OpenApiResult<JDGoodsListResultBean> jdGoodsListResultBeanOpenApiResult) throws Exception {
                            if (jdGoodsListResultBeanOpenApiResult.isSuccess()) {
                                List<JDGoodsItemBean> datas = jdGoodsListResultBeanOpenApiResult.getData().getDatas();
                                for (JDGoodsItemBean goodsItemBean : datas) {
                                    goodsItemBean.setImagePath("http://img13.360buyimg.com/n0/" + goodsItemBean.getImagePath());
                                }
                            }
                        }
                    })
                    .subscribeOn(Schedulers.io())
                    .observeOn(AndroidSchedulers.mainThread())
                    .subscribe(new OpenApiResultObserver<JDGoodsListResultBean>() {
                        @Override
                        public void onLoading(Disposable d) {

                        }

                        @Override
                        public void onSuccess(OpenApiResult<JDGoodsListResultBean> result, JDGoodsListResultBean jdGoodsListResultBean) {
                            pageInfo.increasePage();
                            getView().loadmoreGoodsSuccess(jdGoodsListResultBean);
                        }

                        @Override
                        public void onApiError(OpenApiResult<JDGoodsListResultBean> result, int code, String msg) {
                            getView().loadmoreGoodsServerFailed(msg);
                        }

                        @Override
                        public void onOtherError(Throwable e) {
                            getView().loadmoreGoodsNetFailed(e.getMessage());
                        }

                        @Override
                        public void onLoaded() {

                        }
                    });
        }
    }
}
